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