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