UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'E3esc0zHgUyKVqaTnVBDG2XPZbrWWvo6RKBs+PCIwr4='
WHERE
key_id = 'bfe3eca1e8134c3cb8f7a7c8780177cebb4ac8acd1f1fb7dfd25bee3d257bdc3'
AND (
token = 'E3esc0zHgUyKVqaTnVBDG2XPZbrWWvo6RKBs+PCIwr4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)