hi,
could you please help me in passing object to memcache set() function
actuallly i want to pass my class object as a key to memcache set(key,value) function,
i have tried str() function but i doesn't work
if you can provide a sample code that will be good for me
i am using python 2.5 on my ubuntu machine.
2 1269
hi,
could you please help me in passing object to memcache set() function
actuallly i want to pass my class object as a key to memcache set(key,value) function,
i have tried str() function but i doesn't work
if you can provide a sample code that will be good for me
i am using python 2.5 on my ubuntu machine.
If you will provide a snippet, we'll be glad to take a look at it.
If you will provide a snippet, we'll be glad to take a look at it.
-
import os
-
import memcache
-
import helper
-
import time
-
from dThread import dThread
-
import cPickle as pickle
-
CClientArray = []
-
Objectke = []
-
#j = 1
-
def to_s(val):
-
"""
-
Convert val to string.
-
"""
-
if not isinstance(val, str):
-
return "%s (%s)" % (val, type(val))
-
return val
-
class CClient(dThread):
-
mc = None
-
newval = None
-
#ival = None
-
ObjectKey = None
-
def __init__(self):
-
try:
-
dThread.__init__(self)
-
self.mc = memcache.Client(['192.168.1.68:11211'], debug=0)
-
self.newval = None
-
# self.ival = i
-
self.Objectkey = None
-
#self.ival = i
-
# self.logfile = file(filename, 'w')
-
except:
-
print "in constructor"
-
-
#def __init__(self, value, filename):
-
-
-
-
def setValue(self, ivalue):
-
try:
-
#temp = Objectke[ivalue]
-
-
#key = str(ivalue)
-
-
value = "CClientclass for new test" #+ str(j)
-
# j = j+1
-
self.mc.set(ivalue, value)
-
-
except:
-
print "in setvalue"
-
-
def showVal(self):
-
print self.newval
-
-
def getValue(self,ivalue):
-
try:
-
temp = Objectke[ivalue]
-
#print temp
-
#i = str(temp)
-
#print self.mc.get(temp)
-
#showVal();
-
except:
-
print "in getvalue"
-
-
def setObjectValue(self, key):
-
self.Objectkey = key
-
-
def getObjectValue(self ):
-
return self.Objectkey
-
-
-
def startClient():
-
mc = memcache.Client(['192.168.1.68:11211'], debug=0)
-
mc.flush_all()
-
for i in range(1, 10):
-
obj = CClient()
-
CClientArray.append(obj)
-
try:
-
temp = pickle.dumps(obj)
-
obj.setValue(temp)
-
except:
-
print "error in appending"
-
-
print "after set the value "
-
"""
-
for i in range(1, 10):
-
obj = CClientArray[i]
-
obj.getValue(i)
-
-
print "after getting the value"
-
"""
-
Thanx for replying me,
i just want to pass object of CClient class int memcache set function as a key,
if you can make this code work this will be good for me.
Thanx
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mr A |
last post by:
Hi!
I've been thinking about passing parameteras using references instead
of pointers in order to emphasize that the parameter must be an
object.
Exemple:
void func(Objec& object); //object...
|
by: Zlatko Matić |
last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL
Server) and that we want to execute some parameterized query as a
pass.through query. How can we pass parameters to the...
|
by: Andrew Mueller |
last post by:
Hello,
I tried this question prior and got no response, so thought I would try
to explain differently..
I am not sure which type of object to pass between a VB 6.0 ActiveX dll and
C#. I am...
|
by: z_learning_tester |
last post by:
I'm reading the MS press C# book and there seems to be a contradiction.
Please tell me which one is correct, 1 or 2.
Thanks!
Jeff
1. First it gives the code below saying that it prints 0 then...
|
by: John Bailo |
last post by:
I want to pass a SqlCommand object as a input parameter to a method.
I want to pass the SqlCommand "by value" so that any updates to the
original object are *not* reflected in the object within...
|
by: Jon Slaughter |
last post by:
I'm reading a book on C# and it says there are 4 ways of passing types:
1. Pass value type by value
2. Pass value type by reference
3. Pass reference by value
4. Pass reference by reference.
...
|
by: Francois Appert |
last post by:
This post was originally in the C# Corner site, but their server is
down. I'd like to see if this group can answer.
I program in C++ and am learning C#.
The issue is: why should anybody...
|
by: Bryan Parkoff |
last post by:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope....
|
by: raylopez99 |
last post by:
I'm posting this fragment from another thread to frame the issue
clearer.
How to pass an object to a function/method call in C# that will
guarantee not to change the object?* In C++, as seen...
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms....
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |