UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Z36kLeTw93ekaXwGbsvfyMHb7P2h+DMgRnJe78yRY14='
WHERE
key_id = 'f0978035a88716d45156772ce68f93436f282ea874017fcfc33ca10082e78bed'
AND (
token = 'Z36kLeTw93ekaXwGbsvfyMHb7P2h+DMgRnJe78yRY14='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)