UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'KhfiIFJxIMt8xZcl2Km6hoqIgZqiEg1qaeC7v7hwJO4='
WHERE
key_id = 'd10f2d141a2b2d664408ce2360301271eaf1c7e7a320d87003b80fe6903dee8d'
AND (
token = 'KhfiIFJxIMt8xZcl2Km6hoqIgZqiEg1qaeC7v7hwJO4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)