pic use memcache as a RAM memory
first i lock memcache (with my today lock function)
set a key to 0
i read data from pic, and put at memcache
after 128 writes i put a sum (save this sum at pic internal memory)
total bytes is about 1MB(1048576 bytes) (pic don't have this memory,
it's a ADC read 2Bytes/read)
after all 1MB sent, i check all sums with my internal memory, to make
sure some data wasn't lost
if lost, i start a new lock
set a key to 1
after it, i unlock memcache (my today unlock function)
wait just some minutes
if get set isn't 2 return to first lock
if 2 continue with another function inside pic program

after key=1 my server (another app), process and set key to 2  if ok
i'm using memcache as a key-value and as a server-client protocol
ok it's not fast, but it's work
the other implementation use a server side, and a ARM client side
server don't use more memcache, ARM doesn't use it too, i'm using
mysql at ARM side and tcp/ip socket to contact my app about new data
(it's faster than a table update in mysql)



2011/2/5 dormando <dorma...@rydia.net>:
>> problem:
>> today i need 4 packets to make 'lock'/'unlock' using memcache
>> i need to use less ROM/CPU/RAM/network at client side
>>
>> solution:
>> 1) make server side lock function with 2 packet (with atomic operations)
>> 2) make a proxy if function = lock/unlock, proxy make these packets to
>> server (i don't have atomic here, but i can implement with a big work
>> on protocol, maybe a new memcached hehe)
>>
>> i will try the second one without atomic (today i'm using it, i have
>> some problems, but client side workaround it with more packets...
>> (retry) )
>> the first is better (i don't need a proxy, i have less packets, use
>> less cpu, ram, rom, time)
>>
>> packets:
>> LOCK
>> add value (1 packet sent by client, 1 packet sent by server)
>> if no error (end here)
>> if value exist
>> read value (1packet sent by client, 1 packet sent by server)
>> if value=my value (my lock) if not (not my lock)
>>
>> UNLOCK
>> read value (1packet sent by client, 1 packet sent by server)
>> if value != my value
>> (end here)
>> delete value (1packet sent by client, 1 packet sent by server)
>> (end here)
>
> I think he means to step back a bit, and describe what problem it is that
> lead you to needing to access memcached from a PIC.
>
> ie; what is the specific work that the PIC is doing which needs
> synchronization and perhaps repeated accesses to memcached?
>



-- 
Roberto Spadim
Spadim Technology / SPAEmpresarial

Reply via email to